Language model
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
A language model is a model of the human brain's ability to produce natural language.cite-ref-1[1]cite-ref-2[2] Language models are useful for a variety of tasks, including speech recognition,cite-ref-3[3] machine translation,cite-ref-semantic-parsing-as-machine-translation-4-0[4] natural language generation (generating more human-like text), optical character recognition, route optimization,cite-ref-5[5] handwriting recognition,cite-ref-6[6] grammar induction,cite-ref-7[7] and information retrieval.cite-ref-ponte1998-8-0[8]cite-ref-hiemstra1998-9-0[9]
Large language models (LLMs), currently their most advanced form, are predominantly based on transformers trained on larger datasets (frequently using texts scraped from the public internet). They have superseded recurrent neural network-based models, which had previously superseded the purely statistical models, such as the word n-gram language model.
Contents
• History
• See also
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
History
Noam Chomsky did pioneering work on language models in the 1950s by developing a theory of formal grammars.cite-ref-10[10]
In 1980, statistical approaches were explored and found to be more useful for many purposes than rule-based formal grammars. Discrete representations like word n-gram language models, with probabilities for discrete combinations of words, made significant advances.
In the 2000s, continuous representations for words, such as word embeddings, began to replace discrete representations.cite-ref-11[11] Typically, the representation is a real-valued vector that encodes the meaning of the word in such a way that the words that are closer in the vector space are expected to be similar in meaning, and common relationships between pairs of words like plurality or gender.
Pure statistical models
In 1980, the first significant statistical language model was proposed, and during the decade IBM performed ‘Shannon-style’ experiments, in which potential sources for language modeling improvement were identified by observing and analyzing the performance of human subjects in predicting or correcting text.cite-ref-12[12]
Models based on word n -grams
A word n-gram language model is a purely statistical model of language. It has been superseded by recurrent neural network–based models, which have been superseded by large language models.cite-ref-13[13] It is based on an assumption that the probability of the next word in a sequence depends only on a fixed size window of previous words. If only one previous word is considered, it is called a bigram model; if two words, a trigram model; if n − 1 words, an n-gram model.cite-ref-word-n-gram-language-model-jm-14-0[14] Special tokens are introduced to denote the start and end of a sentence ⟨ ⟨ s ⟩ ⟩ {\displaystyle \langle s\rangle } and ⟨ ⟨ / s ⟩ ⟩ {\displaystyle \langle /s\rangle } .
To prevent a zero probability being assigned to unseen words, each word's probability is slightly higher than its frequency count in a
corpus
. To calculate it, various methods were used, from simple "add-one" smoothing (assign a count of 1 to unseen
n
-grams, as an
uninformative prior
) to more sophisticated models, such as
Good–Turing discounting
or
back-off models
.
Exponential
Maximum entropy language models encode the relationship between a word and the n-gram history using feature functions. The equation is
P ( w m ∣ ∣ w 1 , … … , w m − − 1 ) = 1 Z ( w 1 , … … , w m − − 1 ) exp ( a T f ( w 1 , … … , w m ) ) {\displaystyle P(w_{m}\mid w_{1},\ldots ,w_{m-1})={\frac {1}{Z(w_{1},\ldots ,w_{m-1})}}\exp(a^{T}f(w_{1},\ldots ,w_{m}))}
where Z ( w 1 , … … , w m − − 1 ) {\displaystyle Z(w_{1},\ldots ,w_{m-1})} is the partition function, a {\displaystyle a} is the parameter vector, and f ( w 1 , … … , w m ) {\displaystyle f(w_{1},\ldots ,w_{m})} is the feature function. In the simplest case, the feature function is just an indicator of the presence of a certain n-gram. It is helpful to use a prior on a {\displaystyle a} or some form of regularization.
The log-bilinear model is another example of an exponential language model.
Skip-gram model
Skip-gram language model is an attempt at overcoming the data sparsity problem that the preceding model (i.e. word n-gram language model) faced. Words represented in an embedding vector were not necessarily consecutive anymore, but could leave gaps that are skipped over (thus the name "skip-gram").cite-ref-15[15]
Formally, a k-skip-n-gram is a length-n subsequence where the components occur at distance at most k from each other.
For example, in the input text:
the rain in Spain falls mainly on the plain
the set of 1-skip-2-grams includes all the bigrams (2-grams), and in addition the subsequences
the in, rain Spain, in falls, Spain mainly, falls on, mainly the, and on plain.
In skip-gram model, semantic relations between words are represented by linear combinations, capturing a form of compositionality. For example, in some such models, if v is the function that maps a word w to its n-d vector representation, then
v ( k i n g ) − − v ( m a l e ) + v ( f e m a l e ) ≈ ≈ v ( q u e e n ) {\displaystyle v(\mathrm {king} )-v(\mathrm {male} )+v(\mathrm {female} )\approx v(\mathrm {queen} )}
where ≈ is made precise by stipulating that its right-hand side must be the
nearest neighbor
of the value of the left-hand side.
Neural models
Recurrent neural network
Continuous representations or embeddings of words are produced in recurrent neural network-based language models (known also as continuous space language models).cite-ref-18[18] Such continuous space embeddings help to alleviate the curse of dimensionality, which is the consequence of the number of possible sequences of words increasing exponentially with the size of the vocabulary, further causing a data sparsity problem. Neural networks avoid this problem by representing words as non-linear combinations of weights in a neural net.cite-ref-bengio-19-0[19]
Large language models
A
large language model
(LLM) is a language model trained with
self-supervised
machine learning
on a vast amount of text, designed for
natural language processing
tasks, especially
language generation
. The largest and most capable LLMs are
generative pretrained transformers
(GPTs), which are largely used in
generative
chatbots
such as
ChatGPT
,
Gemini
or
Claude
. LLMs can be
fine-tuned
for specific tasks or guided by
prompt engineering
.
These models acquire
predictive power
regarding
syntax
,
semantics
, and
ontologies
inherent in human
language corpora
, but they also inherit inaccuracies and
biases
present in the
data
they are trained in.
Although sometimes matching human performance, it is not clear whether they are plausible cognitive models. At least for recurrent neural networks, it has been shown that they sometimes learn patterns that humans do not, but fail to learn patterns that humans typically do.cite-ref-23[23]
Evaluation and benchmarks
Evaluation of the quality of language models is mostly done by comparison to human created sample benchmarks created from typical language-oriented tasks. Other, less established, quality tests examine the intrinsic character of a language model or compare two such models. Since language models are typically intended to be dynamic and to learn from data they see, some proposed models investigate the rate of learning, e.g., through inspection of learning curves.cite-ref-24[24]
Various data sets have been developed for use in evaluating language processing systems.cite-ref-0-25-0[25] These include:
• Massive Multitask Language Understanding (MMLU)cite-ref-26[26]
• Corpus of Linguistic Acceptabilitycite-ref-27[27]
• GLUE benchmarkcite-ref-28[28]
• Microsoft Research Paraphrase Corpuscite-ref-29[29]
• Multi-Genre Natural Language Inference
• Question Natural Language Inference
• Quora Question Pairscite-ref-30[30]
• Recognizing Textual Entailmentcite-ref-31[31]
• Semantic Textual Similarity Benchmark
• SQuAD question answering Testcite-ref-32[32]
• Winograd NLI
• BoolQ, PIQA, SIQA, HellaSwag, WinoGrande, ARC, OpenBookQA, NaturalQuestions, TriviaQA, RACE, BIG-bench hard, GSM8k, RealToxicityPrompts, WinoGender, CrowS-Pairscite-ref-34[34]
See also
References
cite-note-22. ↑ citerefjurafskymartin2021Jurafsky, Dan; Martin, James H. (2021). "N-gram Language Models" (PDF). Speech and Language Processing (3rd ed.). Archived from the original on 22 May 2022. Retrieved 24 May 2022.
cite-note-33. ↑ Kuhn, Roland, and Renato De Mori (1990). "A cache-based natural language model for speech recognition". IEEE transactions on pattern analysis and machine intelligence 12.6: 570–583.
cite-note-semantic-parsing-as-machine-translation-44. ↑ Andreas, Jacob, Andreas Vlachos, and Stephen Clark (2013). "Semantic parsing as machine translation" Archived 15 August 2020 at the Wayback Machine. Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers).
cite-note-55. ↑ citerefliuwuliuwang2023Liu, Yang; Wu, Fanyou; Liu, Zhiyuan; Wang, Kai; Wang, Feiyue; Qu, Xiaobo (2023). "Can language models be used for real-world urban-delivery route optimization?". The Innovation. 4 (6): 100520. Bibcode:2023Innov...400520L. doi:10.1016/j.xinn.2023.100520. PMC 10587631. PMID 37869471.
cite-note-66. ↑ Pham, Vu, et al (2014). "Dropout improves recurrent neural networks for handwriting recognition" Archived 11 November 2020 at the Wayback Machine. 14th International Conference on Frontiers in Handwriting Recognition. IEEE.
cite-note-77. ↑ Htut, Phu Mon, Kyunghyun Cho, and Samuel R. Bowman (2018). "Grammar induction with neural language models: An unusual replication" Archived 14 August 2022 at the Wayback Machine. arXiv:1808.10000.
cite-note-hiemstra1998-99. ↑ citerefhiemstra1998Hiemstra, Djoerd (1998). A linguistically motivated probabilistically model of information retrieval. Proceedings of the 2nd European conference on Research and Advanced Technology for Digital Libraries. LNCS, Springer. pp. 569–584. doi:10.1007/3-540-49653-X_34.
cite-note-1111. ↑ "The Nature Of Life, The Nature Of Thinking: Looking Back On Eugene Charniak's Work And Life". 22 February 2022. Archived from the original on 3 November 2024. Retrieved 5 February 2025.
cite-note-1313. ↑ citerefbengioducharmevincentjanvin2003Bengio, Yoshua; Ducharme, Réjean; Vincent, Pascal; Janvin, Christian (1 March 2003). "A neural probabilistic language model". The Journal of Machine Learning Research. 3: 1137–1155 – via ACM Digital Library.
cite-note-word-n-gram-language-model-jm-1414. ↑ citerefjurafskymartin2023Jurafsky, Dan; Martin, James H. (7 January 2023). "N-gram Language Models". Speech and Language Processing (PDF) (3rd edition draft ed.). Retrieved 24 May 2022.
cite-note-1515. ↑ citerefdavid-guthrie2006David Guthrie; et al. (2006). "A Closer Look at Skip-gram Modelling" (PDF). Archived from the original (PDF) on 17 May 2017. Retrieved 27 April 2014.
cite-note-word-n-gram-language-model-mikolov-161. citerefmikolovchencorradodean2013Mikolov, Tomas; Chen, Kai; Corrado, Greg; Dean, Jeffrey (2013). "Efficient estimation of word representations in vector space". arXiv:1301.3781 [cs.CL].
cite-note-word-n-gram-language-model-compositionality-172. citerefmikolovsutskeverchencorrado2013Mikolov, Tomas; Sutskever, Ilya; Chen, Kai; Corrado, Greg S.; Dean, Jeff (2013). Distributed Representations of Words and Phrases and their Compositionality (PDF). Advances in Neural Information Processing Systems. pp. 3111–3119. Archived (PDF) from the original on 29 October 2020. Retrieved 22 June 2015.
cite-note-1818. ↑ citerefkarpathyKarpathy, Andrej. "The Unreasonable Effectiveness of Recurrent Neural Networks". Archived from the original on 1 November 2020. Retrieved 27 January 2019.
cite-note-bengio-1919. ↑ citerefbengio2008Bengio, Yoshua (2008). "Neural net language models". Scholarpedia. Vol. 3. p. 3881. Bibcode:2008SchpJ...3.3881B. doi:10.4249/scholarpedia.3881. Archived from the original on 26 October 2020. Retrieved 28 August 2015.
cite-note-large-language-model-few-shot-learners2-203. citerefbrownmannrydersubbiah2020Brown, Tom B.; Mann, Benjamin; Ryder, Nick; Subbiah, Melanie; Kaplan, Jared; Dhariwal, Prafulla; Neelakantan, Arvind; Shyam, Pranav; Sastry, Girish; Askell, Amanda; Agarwal, Sandhini; Herbert-Voss, Ariel; Krueger, Gretchen; Henighan, Tom; Child, Rewon; Ramesh, Aditya; Ziegler, Daniel M.; Wu, Jeffrey; Winter, Clemens; Hesse, Christopher; Chen, Mark; Sigler, Eric; Litwin, Mateusz; Gray, Scott; Chess, Benjamin; Clark, Jack; Berner, Christopher; McCandlish, Sam; Radford, Alec; Sutskever, Ilya; Amodei, Dario (December 2020). Larochelle, H.; Ranzato, M.; Hadsell, R.; Balcan, M.F.; Lin, H. (eds.). "Language Models are Few-Shot Learners" (PDF). Advances in Neural Information Processing Systems. 33. Curran Associates, Inc.: 1877–1901. arXiv:2005.14165. Archived (PDF) from the original on 17 November 2023. Retrieved 14 March 2023.
cite-note-214. citereffathallahdasde-giorgispoltronieri2024Fathallah, Nadeen; Das, Arunav; De Giorgis, Stefano; Poltronieri, Andrea; Haase, Peter; Kovriguina, Liubov (26 May 2024). NeOn-GPT: A Large Language Model-Powered Pipeline for Ontology Learning (PDF). Extended Semantic Web Conference 2024. Hersonissos, Greece.
cite-note-large-language-model-manning-2022-225. citerefmanning2022Manning, Christopher D. (2022). "Human Language Understanding & Reasoning". Daedalus. 151 (2): 127–138. doi:10.1162/daed_a_01905. S2CID 248377870. Archived from the original on 17 November 2023. Retrieved 9 March 2023.
cite-note-2323. ↑ citerefhornsteinlasnikpatel-groszyang2018Hornstein, Norbert; Lasnik, Howard; Patel-Grosz, Pritty; Yang, Charles (9 January 2018). Syntactic Structures after 60 Years: The Impact of the Chomskyan Revolution in Linguistics. Walter de Gruyter GmbH & Co KG. ISBN 978-1-5015-0692-5. Archived from the original on 16 April 2023. Retrieved 11 December 2021.
cite-note-2424. ↑ citerefkarlgrenschutze2015Karlgren, Jussi; Schutze, Hinrich (2015), "Evaluating Learning Language Representations", International Conference of the Cross-Language Evaluation Forum, Lecture Notes in Computer Science, Springer International Publishing, pp. 254–260, doi:10.1007/978-3-319-64206-2_8, ISBN 9783319642055
cite-note-2626. ↑ citerefhendrycks2023Hendrycks, Dan (14 March 2023), Measuring Massive Multitask Language Understanding, archived from the original on 15 March 2023, retrieved 15 March 2023
cite-note-2727. ↑ "The Corpus of Linguistic Acceptability (CoLA)". nyu-mll.github.io. Archived from the original on 7 December 2020. Retrieved 25 February 2019.
cite-note-2828. ↑ "GLUE Benchmark". gluebenchmark.com. Archived from the original on 4 November 2020. Retrieved 25 February 2019.
cite-note-2929. ↑ "Microsoft Research Paraphrase Corpus". Microsoft Download Center. Archived from the original on 25 October 2020. Retrieved 25 February 2019.
cite-note-3131. ↑ citerefsammons-v-g-vinod-vydiswaran-dan-rothvydiswaranrothSammons, V.G.Vinod Vydiswaran, Dan Roth, Mark; Vydiswaran, V.G.; Roth, Dan. "Recognizing Textual Entailment" (PDF). Archived from the original (PDF) on 9 August 2017. Retrieved 24 February 2019.{{cite web}}: CS1 maint: multiple names: authors list (link)
cite-note-3232. ↑ "The Stanford Question Answering Dataset". rajpurkar.github.io. Archived from the original on 30 October 2020. Retrieved 25 February 2019.
cite-note-3333. ↑ "Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank". nlp.stanford.edu. Archived from the original on 27 October 2020. Retrieved 25 February 2019.
cite-note-3434. ↑ "llama/MODEL_CARD.md at main · meta-llama/llama". GitHub. Retrieved 28 December 2024.
Further reading
• citerefchenjoshua-goodman1998Chen, Stanley F.; Joshua Goodman (1998). An Empirical Study of Smoothing Techniques for Language Modeling (Technical report). Harvard University. CiteSeerX 10.1.1.131.5458.